home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / datash1a / frmdatas.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-09  |  5.1 KB  |  137 lines

  1. VERSION 5.00
  2. Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
  3. Begin VB.Form frmDataShape 
  4.    Caption         =   "Data Shaping Basics"
  5.    ClientHeight    =   4890
  6.    ClientLeft      =   60
  7.    ClientTop       =   345
  8.    ClientWidth     =   7365
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   4890
  11.    ScaleWidth      =   7365
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.ListBox List1 
  14.       Height          =   1230
  15.       ItemData        =   "frmDataShape.frx":0000
  16.       Left            =   480
  17.       List            =   "frmDataShape.frx":0002
  18.       TabIndex        =   1
  19.       Top             =   3210
  20.       Width           =   2445
  21.    End
  22.    Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHFlexGrid1 
  23.       Bindings        =   "frmDataShape.frx":0004
  24.       Height          =   2535
  25.       Left            =   450
  26.       TabIndex        =   0
  27.       Top             =   360
  28.       Width           =   6465
  29.       _ExtentX        =   11404
  30.       _ExtentY        =   4471
  31.       _Version        =   393216
  32.       Cols            =   5
  33.       DataMember      =   "PhoneNumbers"
  34.       _NumberOfBands  =   2
  35.       _Band(0).Cols   =   4
  36.       _Band(0).GridLinesBand=   1
  37.       _Band(0).TextStyleBand=   0
  38.       _Band(0).TextStyleHeader=   0
  39.       _Band(0)._NumMapCols=   3
  40.       _Band(0)._MapCol(0)._Name=   "PhoneNumber"
  41.       _Band(0)._MapCol(0)._Caption=   "Phone Number"
  42.       _Band(0)._MapCol(0)._RSIndex=   0
  43.       _Band(0)._MapCol(1)._Name=   "Association"
  44.       _Band(0)._MapCol(1)._RSIndex=   1
  45.       _Band(0)._MapCol(2)._Name=   "Name"
  46.       _Band(0)._MapCol(2)._RSIndex=   2
  47.       _Band(1).BandIndent=   1
  48.       _Band(1).Cols   =   1
  49.       _Band(1).GridLinesBand=   1
  50.       _Band(1).TextStyleBand=   0
  51.       _Band(1).TextStyleHeader=   0
  52.       _Band(1)._ParentBand=   0
  53.       _Band(1)._NumMapCols=   2
  54.       _Band(1)._MapCol(0)._Name=   "Family"
  55.       _Band(1)._MapCol(0)._RSIndex=   0
  56.       _Band(1)._MapCol(1)._Name=   "PhoneNumber"
  57.       _Band(1)._MapCol(1)._RSIndex=   1
  58.       _Band(1)._MapCol(1)._Hidden=   -1  'True
  59.    End
  60.    Begin VB.Label Label1 
  61.       Caption         =   $"frmDataShape.frx":0023
  62.       Height          =   885
  63.       Left            =   3330
  64.       TabIndex        =   2
  65.       Top             =   3240
  66.       Width           =   3615
  67.    End
  68. Attribute VB_Name = "frmDataShape"
  69. Attribute VB_GlobalNameSpace = False
  70. Attribute VB_Creatable = False
  71. Attribute VB_PredeclaredId = True
  72. Attribute VB_Exposed = False
  73. Option Explicit
  74. Dim blnLoadingForm As Boolean
  75. '*******************************************************************************************
  76. '* Written by Timothy A. Vanover 10/9/1999
  77. '* This project is meant to explore very basic data shaping, Hierarchical Recordsets.
  78. '* To gain the most of this project you must explore DataEnvironment1 throughly. There are
  79. '* several properties, queries, and relationships, and a connection object that you have
  80. '* to understand to make Hierarchical Recordsets, which the basics are explored here. Also
  81. '* a good look at the Access Database and the table relationship would help gain a good
  82. '* start on "Data Shaping".
  83. '*******************************************************************************************
  84. Private Sub Form_Load()
  85.     Dim i As Integer
  86.     blnLoadingForm = True 'use to prevent List_Click From firing requery
  87.     With MSHFlexGrid1 'set Column widths
  88.         .ColWidth(0, 0) = 400
  89.         .ColWidth(1, 0) = 1500
  90.         .ColWidth(2, 0) = 1500
  91.         .ColWidth(3, 0) = 1500
  92.         .ColWidth(0, 1) = 1500
  93.     End With
  94.         
  95.     With DataEnvironment1
  96.         .rsAssociations.Open
  97.         If Not .rsAssociations.BOF Then 'check for BOF or EOF before moving
  98.             .rsAssociations.MoveFirst
  99.             For i = 0 To .rsAssociations.RecordCount - 1
  100.                 List1.AddItem .rsAssociations!Association 'add record to listbox
  101.                 If Not .rsAssociations.EOF Then
  102.                     .rsAssociations.MoveNext 'move to next record
  103.                 End If
  104.             Next i
  105.         End If
  106.         
  107.     End With
  108.     blnLoadingForm = False
  109. End Sub
  110. Private Sub Form_Unload(Cancel As Integer)
  111.     'just a bit of cleanup
  112.     With DataEnvironment1
  113.         .rsAssociations.Close
  114.         .rsPhoneNumbers.Close
  115.         .Connection1.Close
  116.     End With
  117.     Set DataEnvironment1 = Nothing
  118. End Sub
  119. Private Sub List1_Click()
  120.     'closing the recordset may not be needed. There is a Filter, and a requery
  121.     'I wanted to show the Changing of a named Parameter value which requires
  122.     'the recordset to be closed.
  123.     If Not blnLoadingForm Then
  124.         With DataEnvironment1
  125.             .rsPhoneNumbers.Close
  126.             .Commands.Item("PhoneNumbers").Parameters("Association").Value = Trim$(List1.Text)
  127.             .Commands.Item("PhoneNumbers").Execute
  128.         End With
  129.         With MSHFlexGrid1
  130.            Set .DataSource = Nothing
  131.            Set .DataSource = DataEnvironment1
  132.            .DataMember = "PhoneNumbers"
  133.         End With
  134.         
  135.     End If
  136. End Sub
  137.